<template>
  <div>
    <ul>
      <li v-for="(random, index) in arr" :key="index">
        <p>{{random}}</p>
        <button @click= "del(index)" >删除</button>
      </li>
    </ul>
    <button @click= "create">生成</button>
  </div>
</template>

<script>
export default {
  data () {
    return {
      arr: [1, 5, 3]
    }
  },
  methods: {
    del (index) {
      this.arr.splice(index, 1)
    },
    create () {
      this.arr.push(Math.floor(Math.random() * 10))
    }

  }
}
</script>

<style scoped lang='less'>
  p{
    display: inline-block;
    padding-right: 12px;
  }
</style>
